VIF.network & network.VIFs & one-to-many\\
host.metrics & host\_metrics.host & one-to-one\\
PIF.metrics & PIF\_metrics.PIF & one-to-one\\
-VM.metrics & VM\_metrics.VM & one-to-one\\
PIF.host & host.PIFs & one-to-many\\
PIF.network & network.PIFs & one-to-many\\
SR.VDIs & VDI.SR & many-to-one\\
$\mathit{RW}$ & {\tt VCPUs/params} & (string $\rightarrow$ string) Map & configuration parameters for the selected VCPU policy \\
$\mathit{RW}$ & {\tt VCPUs/max} & int & Max number of VCPUs \\
$\mathit{RW}$ & {\tt VCPUs/at\_startup} & int & Boot number of VCPUs \\
-$\mathit{RO}_\mathit{ins}$ & {\tt VCPUs/number} & int & Current number of VCPUs \\
-$\mathit{RO}_\mathit{run}$ & {\tt VCPUs/utilisation} & (int $\rightarrow$ float) Map & Utilisation for all of guest's current VCPUs \\
$\mathit{RW}$ & {\tt actions/after\_shutdown} & on\_normal\_exit & action to take after the guest has shutdown itself \\
$\mathit{RW}$ & {\tt actions/after\_reboot} & on\_normal\_exit & action to take after the guest has rebooted itself \\
$\mathit{RW}$ & {\tt actions/after\_crash} & on\_crash\_behaviour & action to take if the guest crashes \\
$\mathit{RO}_\mathit{run}$ & {\tt tools\_version} & (string $\rightarrow$ string) Map & versions of installed paravirtualised drivers \\
$\mathit{RW}$ & {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
$\mathit{RO}_\mathit{run}$ & {\tt is\_control\_domain} & bool & true if this is a control domain (domain 0 or a driver domain) \\
-$\mathit{RO}_\mathit{ins}$ & {\tt metrics} & VM\_metrics ref & metrics associated with this VM. \\
+$\mathit{RO}_\mathit{run}$ & {\tt metrics} & VM\_metrics ref & metrics associated with this VM. \\
\hline
\end{longtable}
\subsection{Additional RPCs associated with class: VM}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~get\_VCPUs\_number}
-
-{\bf Overview:}
-Get the VCPUs/number field of the given VM.
-
- \noindent {\bf Signature:}
-\begin{verbatim} int get_VCPUs_number (session_id s, VM ref self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
-
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & self & reference to the object \\ \hline
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:}
-{\tt
-int
-}
-
-
-value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~get\_VCPUs\_utilisation}
-
-{\bf Overview:}
-Get the VCPUs/utilisation field of the given VM.
-
- \noindent {\bf Signature:}
-\begin{verbatim} ((int -> float) Map) get_VCPUs_utilisation (session_id s, VM ref self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
-
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & self & reference to the object \\ \hline
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:}
-{\tt
-(int $\rightarrow$ float) Map
-}
-
-
-value of the field
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
Quals & Field & Type & Description \\
\hline
$\mathit{RO}_\mathit{run}$ & {\tt uuid} & string & unique identifier/object reference \\
-$\mathit{RO}_\mathit{ins}$ & {\tt VM} & VM ref & VM to which these metrics apply \\
$\mathit{RO}_\mathit{run}$ & {\tt memory/actual} & int & Guest's actual memory (bytes) \\
$\mathit{RO}_\mathit{run}$ & {\tt VCPUs/number} & int & Current number of VCPUs \\
$\mathit{RO}_\mathit{run}$ & {\tt VCPUs/utilisation} & (int $\rightarrow$ float) Map & Utilisation for all of guest's current VCPUs \\
}
-value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~get\_VM}
-
-{\bf Overview:}
-Get the VM field of the given VM\_metrics.
-
- \noindent {\bf Signature:}
-\begin{verbatim} (VM ref) get_VM (session_id s, VM_metrics ref self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
-
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM\_metrics ref } & self & reference to the object \\ \hline
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:}
-{\tt
-VM ref
-}
-
-
value of the field
\vspace{0.3cm}
\vspace{0.3cm}
/*
- * Copyright (c) 2006, XenSource Inc.
+ * Copyright (c) 2006-2007, XenSource Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "xen_common.h"
#include "xen_int_float_map.h"
-#include "xen_vm_decl.h"
#include "xen_vm_metrics_decl.h"
{
xen_vm_metrics handle;
char *uuid;
- struct xen_vm_record_opt *vm;
int64_t memory_actual;
int64_t vcpus_number;
xen_int_float_map *vcpus_utilisation;
xen_vm_metrics_get_uuid(xen_session *session, char **result, xen_vm_metrics vm_metrics);
-/**
- * Get the VM field of the given VM_metrics.
- */
-extern bool
-xen_vm_metrics_get_vm(xen_session *session, xen_vm *result, xen_vm_metrics vm_metrics);
-
-
/**
* Get the memory/actual field of the given VM_metrics.
*/
/*
- * Copyright (c) 2006, XenSource Inc.
+ * Copyright (c) 2006-2007, XenSource Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "xen_common.h"
#include "xen_int_float_map.h"
#include "xen_internal.h"
-#include "xen_vm.h"
#include "xen_vm_metrics.h"
{ .key = "uuid",
.type = &abstract_type_string,
.offset = offsetof(xen_vm_metrics_record, uuid) },
- { .key = "VM",
- .type = &abstract_type_ref,
- .offset = offsetof(xen_vm_metrics_record, vm) },
{ .key = "memory_actual",
.type = &abstract_type_int,
.offset = offsetof(xen_vm_metrics_record, memory_actual) },
}
free(record->handle);
free(record->uuid);
- xen_vm_record_opt_free(record->vm);
xen_int_float_map_free(record->vcpus_utilisation);
free(record);
}
}
-bool
-xen_vm_metrics_get_vm(xen_session *session, xen_vm *result, xen_vm_metrics vm_metrics)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vm_metrics }
- };
-
- abstract_type result_type = abstract_type_string;
-
- *result = NULL;
- XEN_CALL_("VM_metrics.get_VM");
- return session->ok;
-}
-
-
bool
xen_vm_metrics_get_memory_actual(xen_session *session, int64_t *result, xen_vm_metrics vm_metrics)
{
#include "xen_vdi.h"
#include "xen_console.h"
#include "xen_vm.h"
+#include "xen_vm_metrics.h"
static void usage()
static xen_vm create_new_vm(xen_session *session, bool hvm);
static void print_vm_power_state(xen_session *session, xen_vm vm);
+static void print_vm_metrics(xen_session *session, xen_vm vm);
static size_t
printf("%s.\n", xen_vm_power_state_to_string(vm_record->power_state));
- for (size_t i = 0; i < vm_record->vcpus_utilisation->size; i++)
- {
- printf("%"PRId64" -> %lf.\n",
- vm_record->vcpus_utilisation->contents[i].key,
- vm_record->vcpus_utilisation->contents[i].val);
- }
+ print_vm_metrics(session, vm);
xen_uuid_bytes_free(vm_uuid_bytes);
xen_uuid_free(vm_uuid);
.memory_static_min = 128,
.vcpus_policy = "credit",
.vcpus_params = vcpus_params,
- .vcpus_number = 2,
.actions_after_shutdown = XEN_ON_NORMAL_EXIT_DESTROY,
.actions_after_reboot = XEN_ON_NORMAL_EXIT_RESTART,
.actions_after_crash = XEN_ON_CRASH_BEHAVIOUR_PRESERVE,
xen_uuid_free(vm_uuid);
}
+
+
+/**
+ * Print the metrics for the given VM.
+ */
+static void print_vm_metrics(xen_session *session, xen_vm vm)
+{
+ xen_vm_metrics vm_metrics;
+ if (!xen_vm_get_metrics(session, &vm_metrics, vm))
+ {
+ print_error(session);
+ return;
+ }
+
+ xen_vm_metrics_record *vm_metrics_record;
+ if (!xen_vm_metrics_get_record(session, &vm_metrics_record, vm_metrics))
+ {
+ xen_vm_metrics_free(vm_metrics);
+ print_error(session);
+ return;
+ }
+
+ for (size_t i = 0; i < vm_metrics_record->vcpus_utilisation->size; i++)
+ {
+ printf("%"PRId64" -> %lf.\n",
+ vm_metrics_record->vcpus_utilisation->contents[i].key,
+ vm_metrics_record->vcpus_utilisation->contents[i].val);
+ }
+
+ xen_vm_metrics_record_free(vm_metrics_record);
+ xen_vm_metrics_free(vm_metrics);
+}